package cn.wangzg.course0802;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

import androidx.annotation.Nullable;

/**
 * Time: 2020/4/9
 * Author: wangzhiguo
 * Description: 功能描述
 */
public class MyHelper extends SQLiteOpenHelper {
    public MyHelper(@Nullable Context context) {
        super(context, "mydb.db", null, 2);//创建数据库
    }

    @Override
    public void onCreate(SQLiteDatabase db) {//创建数据表，只有第一次时执行
        db.execSQL("create table person(id integer primary key autoincrement," +
                "name varchar(20),age int,zy);");
        System.out.println("----------111111-----------");
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        System.out.println("----------"+newVersion+"-----------");
        db.execSQL("alter table person add column zy;");
    }
}
